package com.pesilo.mvc.view
{
	import com.pesilo.mvc.controller.ApplicationFacade;
	import com.pesilo.mvc.model.WatchProxy;
	import com.pesilo.mvc.view.component.show.ShowComponent;
	
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;
	
	public class ShowMediator extends Mediator implements IMediator
	{
		public static const NAME:String="ShowMediator";
		public function ShowMediator(viewComponent:Object)
		{
			super(NAME,viewComponent);
		}
		
		override public function onRegister():void{
			facade.registerMediator(new WatchMediator(view.watchCmp));
		}
		
		override public function listNotificationInterests():Array{
			return[
				ApplicationFacade.SHOW_WATCH_EVENT
			]
		}
		
		override public function handleNotification(notification:INotification):void{
			switch(notification.getName()){
				case ApplicationFacade.SHOW_WATCH_EVENT:
					view.addChild(view.watchCmp);
					(facade.retrieveProxy(WatchProxy.NAME) as WatchProxy).getWatchData();
					break;
			}
		}
		
		protected function get view():ShowComponent{
			return viewComponent as ShowComponent;
		}
	}
}